//
//  CellForRecommendNews.m
//  MY Project For Sport
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 dilo. All rights reserved.
//

#import "CellForRecommendNews.h"
#import "ModelForRecommend.h"
#import <SDWebImage/UIImageView+WebCache.h>
#import <DKNightVersion.h>
#import "UIColor+Wonderful.h"

#define WEIGHTT [UIScreen mainScreen].bounds.size.width / 375
#define HEIGHTT [UIScreen mainScreen].bounds.size.height / 667


@interface CellForRecommendNews ()

@property (nonatomic, retain) UILabel *labelForTitle;
@property (nonatomic, retain) UILabel *labelForContent;
@property (nonatomic, retain) UIImageView *imageViewForNews;
@property (nonatomic, retain) UIView *view;
@end


@implementation CellForRecommendNews

- (void)dealloc {
    [_imageViewForNews release];
    [_labelForContent release];
    [_labelForTitle release];
    [_view release];
    [super dealloc];

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

        self.contentView.dk_backgroundColorPicker = DKColorWithColors([UIColor linenColor], [UIColor grayColor]);

        [self createSubview];
        
    }


    return self;
}
- (void)createSubview {

    
    self.view = [[UIView alloc] init];
    [self.contentView addSubview:self.view];
    [_view release];

    self.labelForContent = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForContent];
    [_labelForContent release];
    
    
    self.labelForTitle = [[UILabel alloc] init];
    [self.contentView addSubview:self.labelForTitle];
    [_labelForTitle release];
    
    
    self.imageViewForNews = [[UIImageView alloc] init];
    [self.contentView addSubview:self.imageViewForNews];
    [_imageViewForNews release];
 
}

-(void)layoutSubviews {

    [super layoutSubviews];
    
    
    self.view.frame = CGRectMake(2, 5, self.contentView.frame.size.width - 4, self.contentView.frame.size.height - 10);
    //self.view.backgroundColor = [UIColor whiteColor];
    self.view.dk_backgroundColorPicker = DKColorWithRGB (0xffffff, 0x343434);

    
    self.imageViewForNews.frame = CGRectMake(2 * WEIGHTT, 5 * HEIGHTT, self.contentView.frame.size.width / 4, self.contentView.frame.size.height - 10 * HEIGHTT);
   // self.imageViewForNews.backgroundColor = [UIColor redColor];
    
    self.labelForTitle.numberOfLines = 0;
    self.labelForTitle.font = [UIFont systemFontOfSize:19];
    self.labelForTitle.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 10 * HEIGHTT, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15* WEIGHTT , (self.contentView.frame.size.height - 20 * HEIGHTT) / 3);
   // self.labelForTitle.backgroundColor = [UIColor orangeColor];
    self.labelForTitle.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    
    self.labelForContent.font = [UIFont systemFontOfSize:15];
    self.labelForContent.textColor = [UIColor grayColor];
    self.labelForContent.numberOfLines = 0;
    self.labelForContent.frame = CGRectMake(self.contentView.frame.size.width / 4 + 10 * WEIGHTT, 15 * HEIGHTT + (self.contentView.frame.size.height - 15 * HEIGHTT) / 3, self.contentView.frame.size.width - self.contentView.frame.size.width / 4 - 15 * WEIGHTT , (self.contentView.frame.size.height - 20 * HEIGHTT) / 3 * 2);
   // self.labelForContent.backgroundColor = [UIColor blueColor];
    
 }

- (void)passModelForRecommend:(ModelForRecommend *)model {

    self.labelForTitle.text = model.stitle;
    self.labelForContent.text = model.wapsummary;
    [self.imageViewForNews sd_setImageWithURL:[NSURL URLWithString:[model.img objectForKey:@"u"]]];
 
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
